﻿
using System.Collections.Generic;
using System.Linq;
using Dexter.DataTransferObject;

namespace Dexter.Domain.Model
{
	public static class CommentHelper
	{
		public static IList<CommentDto> ToDtos(this IEnumerable<Comment> s)
		{
			return s.Select(x => x.ToDto()).ToList();
		}

		public static CommentDto ToDto(this Comment s)
		{
			var r = new CommentDto { Email = s.Email, Id = s.Id, Message = s.Message, Name = s.Name, Item = s.Item.ToDtoLight() };
			
			if (s.Comments != null && s.Comments.Count() > 0)
				r.Comments = s.Comments.ToDtos();

			return r;
		}
	}
}
